First we have a look at the observation data:
Here we could know that it got 18 distance data each time, 20 degrees for each, and the unit should be meter.
Then we implemented the function to calculate the operation between two positions, return its yaw_start, distance and yaw_end.
The next step is to calculating the probability of getting the cur_pose that start from the same prev_pose, given input u. The code is shown below:
Then we update the probabilities in loc.bel_bar based on loc.bel from the previous time step and the odometry motion model.
We need to notice that it is important to filter out the points with relatively low probabilities, otherwise it will stocks the computing progress and takes plenty of time.
Then we compute the final probability:
Here is the final result of the simulation:
The blue line is the groundtruth, the red one is the prediction with out bayes filter, which is extremly unreliable, and the green line is our predicted result using bayes filter, which is much better than the red line.
Here attached is the result in each step:
----------------- 0 -----------------
2024-04-18 00:19:28,760 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:28,773 | INFO |: GT index : (6, 3, 6)
2024-04-18 00:19:28,776 | INFO |: Prior Bel index : (5, 5, 5) with prob = 0.0822345
2024-04-18 00:19:28,777 | INFO |: POS ERROR : (0.287, -0.393, 29.893)
2024-04-18 00:19:28,779 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:31,989 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:19:31,998 | INFO |: GT index : (6, 3, 6)
2024-04-18 00:19:32,002 | INFO |: Bel index : (6, 4, 6) with prob = 1.0
2024-04-18 00:19:32,004 | INFO |: Bel_bar prob at index = 4.827641436902759e-05
2024-04-18 00:19:32,005 | INFO |: GT : (0.287, -0.089, 319.893)
2024-04-18 00:19:32,006 | INFO |: Belief : (0.305, 0.000, -50.000)
2024-04-18 00:19:32,007 | INFO |: POS ERROR : (-0.018, -0.089, 369.893)
2024-04-18 00:19:32,009 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 1 -----------------
2024-04-18 00:19:34,097 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:34,106 | INFO |: GT index : (7, 2, 5)
2024-04-18 00:19:34,106 | INFO |: Prior Bel index : (7, 2, 5) with prob = 0.0940475
2024-04-18 00:19:34,107 | INFO |: POS ERROR : (-0.096, 0.075, 366.975)
2024-04-18 00:19:34,108 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:37,330 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:19:37,336 | INFO |: GT index : (7, 2, 5)
2024-04-18 00:19:37,337 | INFO |: Bel index : (7, 2, 6) with prob = 1.0
2024-04-18 00:19:37,338 | INFO |: Bel_bar prob at index = 0.058752577161981845
2024-04-18 00:19:37,338 | INFO |: GT : (0.513, -0.534, 656.975)
2024-04-18 00:19:37,340 | INFO |: Belief : (0.610, -0.610, -50.000)
2024-04-18 00:19:37,340 | INFO |: POS ERROR : (-0.096, 0.075, 706.975)
2024-04-18 00:19:37,343 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 2 -----------------
2024-04-18 00:19:38,423 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:38,438 | INFO |: GT index : (7, 2, 4)
2024-04-18 00:19:38,440 | INFO |: Prior Bel index : (8, 3, 7) with prob = 0.1294804
2024-04-18 00:19:38,442 | INFO |: POS ERROR : (-0.401, -0.229, 664.055)
2024-04-18 00:19:38,444 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:41,659 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:19:41,670 | INFO |: GT index : (7, 2, 4)
2024-04-18 00:19:41,670 | INFO |: Bel index : (6, 2, 4) with prob = 1.0
2024-04-18 00:19:41,672 | INFO |: Bel_bar prob at index = 0.007730472925824664
2024-04-18 00:19:41,673 | INFO |: GT : (0.513, -0.534, 994.055)
2024-04-18 00:19:41,674 | INFO |: Belief : (0.305, -0.610, -90.000)
2024-04-18 00:19:41,675 | INFO |: POS ERROR : (0.209, 0.075, 1084.055)
2024-04-18 00:19:41,677 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 3 -----------------
2024-04-18 00:19:42,750 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:42,768 | INFO |: GT index : (7, 0, 4)
2024-04-18 00:19:42,770 | INFO |: Prior Bel index : (6, 1, 3) with prob = 0.1721664
2024-04-18 00:19:42,770 | INFO |: POS ERROR : (0.236, -0.012, 1104.055)
2024-04-18 00:19:42,772 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:45,968 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:19:45,980 | INFO |: GT index : (7, 0, 4)
2024-04-18 00:19:45,982 | INFO |: Bel index : (7, 1, 4) with prob = 1.0
2024-04-18 00:19:45,985 | INFO |: Bel_bar prob at index = 0.003243259838345402
2024-04-18 00:19:45,986 | INFO |: GT : (0.542, -0.933, 1354.055)
2024-04-18 00:19:45,987 | INFO |: Belief : (0.610, -0.914, -90.000)
2024-04-18 00:19:45,989 | INFO |: POS ERROR : (-0.068, -0.019, 1444.055)
2024-04-18 00:19:45,990 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 4 -----------------
2024-04-18 00:19:49,085 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:49,101 | INFO |: GT index : (8, 0, 9)
2024-04-18 00:19:49,103 | INFO |: Prior Bel index : (8, 1, 9) with prob = 0.0960649
2024-04-18 00:19:49,105 | INFO |: POS ERROR : (-0.107, -0.158, 1430.952)
2024-04-18 00:19:49,106 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:52,317 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:19:52,335 | INFO |: GT index : (8, 0, 9)
2024-04-18 00:19:52,336 | INFO |: Bel index : (8, 1, 9) with prob = 1.0
2024-04-18 00:19:52,338 | INFO |: Bel_bar prob at index = 0.09606492409285626
2024-04-18 00:19:52,339 | INFO |: GT : (0.807, -1.073, 1800.952)
2024-04-18 00:19:52,340 | INFO |: Belief : (0.914, -0.914, 10.000)
2024-04-18 00:19:52,342 | INFO |: POS ERROR : (-0.107, -0.158, 1790.952)
2024-04-18 00:19:52,344 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 5 -----------------
2024-04-18 00:19:58,428 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:19:58,439 | INFO |: GT index : (11, 1, 11)
2024-04-18 00:19:58,444 | INFO |: Prior Bel index : (11, 3, 11) with prob = 0.0967979
2024-04-18 00:19:58,447 | INFO |: POS ERROR : (-0.240, -0.596, 1800.234)
2024-04-18 00:19:58,449 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:01,650 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:01,665 | INFO |: GT index : (11, 1, 11)
2024-04-18 00:20:01,668 | INFO |: Bel index : (10, 1, 11) with prob = 1.0
2024-04-18 00:20:01,669 | INFO |: Bel_bar prob at index = 0.0016509518870368766
2024-04-18 00:20:01,670 | INFO |: GT : (1.589, -0.901, 2210.234)
2024-04-18 00:20:01,672 | INFO |: Belief : (1.524, -0.914, 50.000)
2024-04-18 00:20:01,673 | INFO |: POS ERROR : (0.065, 0.014, 2160.234)
2024-04-18 00:20:01,674 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 6 -----------------
2024-04-18 00:20:03,743 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:03,760 | INFO |: GT index : (11, 2, 12)
2024-04-18 00:20:03,762 | INFO |: Prior Bel index : (11, 2, 13) with prob = 0.2520128
2024-04-18 00:20:03,765 | INFO |: POS ERROR : (-0.164, 0.095, 2148.888)
2024-04-18 00:20:03,769 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:06,947 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:06,953 | INFO |: GT index : (11, 2, 12)
2024-04-18 00:20:06,954 | INFO |: Bel index : (10, 2, 12) with prob = 1.0
2024-04-18 00:20:06,956 | INFO |: Bel_bar prob at index = 0.0069091741155049855
2024-04-18 00:20:06,957 | INFO |: GT : (1.664, -0.515, 2598.888)
2024-04-18 00:20:06,958 | INFO |: Belief : (1.524, -0.610, 70.000)
2024-04-18 00:20:06,959 | INFO |: POS ERROR : (0.140, 0.095, 2528.888)
2024-04-18 00:20:06,960 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 7 -----------------
2024-04-18 00:20:09,062 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:09,077 | INFO |: GT index : (11, 3, 13)
2024-04-18 00:20:09,078 | INFO |: Prior Bel index : (11, 3, 11) with prob = 0.2005388
2024-04-18 00:20:09,080 | INFO |: POS ERROR : (-0.094, 0.149, 2554.619)
2024-04-18 00:20:09,080 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:12,276 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:12,292 | INFO |: GT index : (11, 3, 13)
2024-04-18 00:20:12,294 | INFO |: Bel index : (11, 3, 13) with prob = 1.0
2024-04-18 00:20:12,295 | INFO |: Bel_bar prob at index = 0.024340030664910955
2024-04-18 00:20:12,297 | INFO |: GT : (1.735, -0.156, 2964.619)
2024-04-18 00:20:12,298 | INFO |: Belief : (1.829, -0.305, 90.000)
2024-04-18 00:20:12,299 | INFO |: POS ERROR : (-0.094, 0.149, 2874.619)
2024-04-18 00:20:12,300 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 8 -----------------
2024-04-18 00:20:15,399 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:15,415 | INFO |: GT index : (11, 5, 14)
2024-04-18 00:20:15,417 | INFO |: Prior Bel index : (11, 5, 14) with prob = 0.1081372
2024-04-18 00:20:15,418 | INFO |: POS ERROR : (-0.098, 0.040, 2877.638)
2024-04-18 00:20:15,420 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:18,618 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:18,630 | INFO |: GT index : (11, 5, 14)
2024-04-18 00:20:18,631 | INFO |: Bel index : (11, 4, 13) with prob = 0.9957032
2024-04-18 00:20:18,632 | INFO |: Bel_bar prob at index = 0.054832723799006014
2024-04-18 00:20:18,633 | INFO |: GT : (1.731, 0.344, 3347.638)
2024-04-18 00:20:18,634 | INFO |: Belief : (1.829, 0.000, 90.000)
2024-04-18 00:20:18,635 | INFO |: POS ERROR : (-0.098, 0.344, 3257.638)
2024-04-18 00:20:18,636 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 9 -----------------
2024-04-18 00:20:21,774 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:21,782 | INFO |: GT index : (11, 6, 16)
2024-04-18 00:20:21,783 | INFO |: Prior Bel index : (10, 5, 15) with prob = 0.1250710
2024-04-18 00:20:21,783 | INFO |: POS ERROR : (0.205, 0.370, 3257.740)
2024-04-18 00:20:21,785 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:24,969 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:24,980 | INFO |: GT index : (11, 6, 16)
2024-04-18 00:20:24,981 | INFO |: Bel index : (11, 7, 16) with prob = 1.0
2024-04-18 00:20:24,981 | INFO |: Bel_bar prob at index = 0.00013572793088119993
2024-04-18 00:20:24,983 | INFO |: GT : (1.729, 0.674, 3747.740)
2024-04-18 00:20:24,984 | INFO |: Belief : (1.829, 0.914, 150.000)
2024-04-18 00:20:24,985 | INFO |: POS ERROR : (-0.100, -0.240, 3597.740)
2024-04-18 00:20:24,987 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 10 -----------------
2024-04-18 00:20:27,074 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:27,088 | INFO |: GT index : (10, 7, 16)
2024-04-18 00:20:27,089 | INFO |: Prior Bel index : (9, 7, 0) with prob = 0.0779881
2024-04-18 00:20:27,090 | INFO |: POS ERROR : (0.086, 0.027, 3929.202)
2024-04-18 00:20:27,091 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:30,303 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:30,318 | INFO |: GT index : (10, 7, 16)
2024-04-18 00:20:30,319 | INFO |: Bel index : (10, 7, 16) with prob = 0.8442309
2024-04-18 00:20:30,320 | INFO |: Bel_bar prob at index = 0.004163980384189426
2024-04-18 00:20:30,321 | INFO |: GT : (1.306, 0.941, 4119.202)
2024-04-18 00:20:30,321 | INFO |: Belief : (1.524, 0.914, 150.000)
2024-04-18 00:20:30,322 | INFO |: POS ERROR : (-0.218, 0.027, 3969.202)
2024-04-18 00:20:30,323 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 11 -----------------
2024-04-18 00:20:33,453 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:33,470 | INFO |: GT index : (7, 6, 3)
2024-04-18 00:20:33,471 | INFO |: Prior Bel index : (4, 8, 2) with prob = 0.0471398
2024-04-18 00:20:33,475 | INFO |: POS ERROR : (0.720, -0.408, 4345.918)
2024-04-18 00:20:33,478 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:36,799 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:36,817 | INFO |: GT index : (7, 6, 3)
2024-04-18 00:20:36,819 | INFO |: Bel index : (7, 7, 3) with prob = 0.9999999
2024-04-18 00:20:36,820 | INFO |: Bel_bar prob at index = 0.006353085002390131
2024-04-18 00:20:36,822 | INFO |: GT : (0.415, 0.811, 4575.918)
2024-04-18 00:20:36,823 | INFO |: Belief : (0.610, 0.914, -110.000)
2024-04-18 00:20:36,824 | INFO |: POS ERROR : (-0.194, -0.103, 4685.918)
2024-04-18 00:20:36,826 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 12 -----------------
2024-04-18 00:20:38,962 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:38,975 | INFO |: GT index : (6, 4, 6)
2024-04-18 00:20:38,977 | INFO |: Prior Bel index : (7, 4, 5) with prob = 0.0515772
2024-04-18 00:20:38,978 | INFO |: POS ERROR : (-0.353, 0.181, 4691.765)
2024-04-18 00:20:38,982 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:42,294 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:42,314 | INFO |: GT index : (6, 4, 6)
2024-04-18 00:20:42,316 | INFO |: Bel index : (5, 4, 6) with prob = 0.9968699
2024-04-18 00:20:42,318 | INFO |: Bel_bar prob at index = 2.7339423406383817e-05
2024-04-18 00:20:42,319 | INFO |: GT : (0.257, 0.181, 4981.765)
2024-04-18 00:20:42,320 | INFO |: Belief : (0.000, 0.000, -50.000)
2024-04-18 00:20:42,322 | INFO |: POS ERROR : (0.257, 0.181, 5031.765)
2024-04-18 00:20:42,324 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 13 -----------------
2024-04-18 00:20:44,455 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:44,462 | INFO |: GT index : (6, 3, 2)
2024-04-18 00:20:44,467 | INFO |: Prior Bel index : (5, 5, 3) with prob = 0.1734820
2024-04-18 00:20:44,468 | INFO |: POS ERROR : (0.012, -0.449, 5023.021)
2024-04-18 00:20:44,472 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:47,705 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:47,723 | INFO |: GT index : (6, 3, 2)
2024-04-18 00:20:47,726 | INFO |: Bel index : (5, 3, 2) with prob = 1.0
2024-04-18 00:20:47,727 | INFO |: Bel_bar prob at index = 3.603467043957661e-05
2024-04-18 00:20:47,728 | INFO |: GT : (0.012, -0.144, 5273.021)
2024-04-18 00:20:47,729 | INFO |: Belief : (0.000, -0.305, -130.000)
2024-04-18 00:20:47,730 | INFO |: POS ERROR : (0.012, 0.160, 5403.021)
2024-04-18 00:20:47,731 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 14 -----------------
2024-04-18 00:20:50,827 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:50,839 | INFO |: GT index : (4, 2, 1)
2024-04-18 00:20:50,840 | INFO |: Prior Bel index : (3, 3, 1) with prob = 0.0851572
2024-04-18 00:20:50,840 | INFO |: POS ERROR : (0.252, -0.007, 5400.003)
2024-04-18 00:20:50,842 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:54,022 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:20:54,036 | INFO |: GT index : (4, 2, 1)
2024-04-18 00:20:54,037 | INFO |: Bel index : (4, 3, 1) with prob = 1.0
2024-04-18 00:20:54,038 | INFO |: Bel_bar prob at index = 0.08144945319795657
2024-04-18 00:20:54,039 | INFO |: GT : (-0.358, -0.312, 5610.003)
2024-04-18 00:20:54,040 | INFO |: Belief : (-0.305, -0.305, -150.000)
2024-04-18 00:20:54,041 | INFO |: POS ERROR : (-0.053, -0.007, 5760.003)
2024-04-18 00:20:54,042 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------
----------------- 15 -----------------
2024-04-18 00:20:57,118 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:20:57,135 | INFO |: GT index : (3, 2, 0)
2024-04-18 00:20:57,136 | INFO |: Prior Bel index : (3, 1, 17) with prob = 0.1012108
2024-04-18 00:20:57,138 | INFO |: POS ERROR : (-0.148, 0.593, 5417.080)
2024-04-18 00:20:57,142 | INFO |: ---------- PREDICTION STATS -----------
2024-04-18 00:21:00,379 | INFO |: ---------- UPDATE STATS -----------
2024-04-18 00:21:00,393 | INFO |: GT index : (3, 2, 0)
2024-04-18 00:21:00,396 | INFO |: Bel index : (3, 3, 0) with prob = 0.5881842
2024-04-18 00:21:00,398 | INFO |: Bel_bar prob at index = 0.006688458174259205
2024-04-18 00:21:00,400 | INFO |: GT : (-0.758, -0.322, 5947.080)
2024-04-18 00:21:00,403 | INFO |: Belief : (-0.610, -0.305, -170.000)
2024-04-18 00:21:00,404 | INFO |: POS ERROR : (-0.148, -0.017, 6117.080)
2024-04-18 00:21:00,405 | INFO |: ---------- UPDATE STATS -----------
-------------------------------------